home *** CD-ROM | disk | FTP | other *** search
- /************************************************************************/
- /* roomb.c */
- /* room code for Citadel bulletin board system */
- /************************************************************************/
-
- /************************************************************************/
- /* History */
- /* */
- /* 85Nov15 HAW Create LIBROOM.C library file. */
- /* 85Nov11 HAW Rewrite Held message. */
- /* 85Nov06 HAW MAXTEXT = 7500, add beep when near end of buffer. */
- /* 85Nov03 HAW Add good_path(). */
- /* 85Aug24 HAW Modify getString() for no return on '?' unless requested*/
- /* 85Aug17 HAW Update to use onLine(). */
- /* 85Jun27 HAW Fix getText to ignore nulls. */
- /* 85Jun22 HAW Rewrite indexRooms() for speed. */
- /* 85May16 HAW Set up <H>old message feature. */
- /* 85Mar13 HAW Move zapRoomFile() out of file. */
- /* 85Mar03 HAW Room replication bug fixed. */
- /* 85Feb22 HAW Implement upload/download stuff. */
- /* 85Feb20 HAW Implement IMPERVIOUS flag. */
- /* 85Jan27 HAW Fix replaceString(). */
- /* 85Jan16 JLS Fix getText so console starting CR creates blank msg. */
- /* 85Jan16 HAW Fix "Continue" extra space problem in editText. */
- /* 85Jan14 HAW Now editText prints recipient on <P>rint formatted. */
- /* 85Jan15 HAW&JLS List rooms deleted by <.ad>. */
- /* 85Jan14 HAW&JLS If room edited is private, now extra question. */
- /* 84Oct15 HAW Rooms were automagically becoming permanent. */
- /* 84Sep17 HAW indexRooms modified so it knows if it's CONFG or CTDL. */
- /* 84Aug30 HAW Into the 16-bit world we leap: MS-DOS! <Gargle> */
- /* 84Jun28 JLS Enhancement: Creator of a room is listed in Aide>. */
- /* 84Jun23 HAW & JLS Local unused variables are zapped. */
- /* 84Jun10 JLS Room cannot have a name of length 0. */
- /* 84May07 JLS & HAW Fix bug in makeRoom to ensure correct g. # inc.ed. */
- /* 84Apr04 HAW Start upgrade to BDS 1.50a. */
- /* 83Feb26 CrT bug in makeRoom when out of rooms fixed. */
- /* 83Feb26 CrT matchString made caseless, normalizeString() */
- /* 83Feb26 CrT "]" directory prompt, user name before prompts */
- /* 82Dec06 CrT 2.00 release. */
- /* 82Nov02 CrT Cleanup prior to V1.2 mods. */
- /* 82Nov01 CrT Proofread for CUG distribution. */
- /* 82Mar27 dvm conversion to v. 1.4 begun */
- /* 82Mar25 dvm conversion for TRS-80/Omikron test started */
- /* 81Dec21 CrT Log file... */
- /* 81Dec20 CrT Messages... */
- /* 81Dec19 CrT Rooms seem to be working... */
- /* 81Dec12 CrT Started. */
- /************************************************************************/
-
- #include "ctdl.h"
-
- /************************************************************************/
- /* Contents */
- /* */
- /* editText() handles the end-of-message-entry menu */
- /* findRoom() find a free room */
- /* getNumber() prompt user for a number, limited range */
- /* getString() read a string in from user */
- /* getText() reads a message in from user */
- /* getYesNo() prompts for a yes/no response */
- /* givePrompt() gives usual "THISROOM>" prompt */
- /* # good_path() gets subdirectory path from sysop */
- /* indexRooms() build RAM index to ctdlroom.sys */
- /* makeRoom() make new room via user dialogue */
- /* matchString() search for given string */
- /* noteRoom() enter room into RAM index */
- /* renameRoom() sysop special to rename rooms */
- /* replaceString() string-substitute for message entry */
- /* strTran() transfer a string */
- /* */
- /* # -- operating system dependent function. */
- /************************************************************************/
-
- /************************************************************************/
- /* External variable declarations in ROOMB.C */
- /************************************************************************/
-
- /*******************************< none >*********************************/
-
- /************************************************************************/
- /* External variable definitions for ROOMB.C */
- /************************************************************************/
- extern struct aRoom roomBuf; /* Room buffer */
- extern struct rTable roomTab[]; /* RAM index */
- extern FILE *roomfl; /* Room file descriptor */
- extern struct config cfg; /* Other variables */
- extern struct msgB msgBuf; /* Message buffer */
- extern struct msgB tempMess; /* For held messages */
- extern struct logBuffer logBuf; /* Person buffer */
- extern int thisRoom; /* Current room */
- extern char outFlag; /* Output flag */
- extern char loggedIn; /* Logged in? */
- extern char haveCarrier; /* Have carrier? */
- extern char onConsole; /* How about on Console? */
- extern char whichIO; /* Where is I/O? */
- extern char debug; /* Debug flag */
- extern char expert; /* expert? */
- extern char *baseRoom;
- extern char heldMessage;
- extern int exitValue;
- extern char echo;
- extern char echoChar;
-
- /************************************************************************/
- /* External function definitions for ROOMB.C */
- /************************************************************************/
- char iChar();
- char getYesNo();
- char toUpper();
- int fread();
-
- /************************************************************************/
- /* editText() handles the end-of-message-entry menu. */
- /* return TRUE to save message to disk, */
- /* FALSE to abort message, and */
- /* ERROR if user decides to continue */
- /************************************************************************/
- int editText(buf, lim)
- char *buf;
- int lim;
- {
- do {
- outFlag = IMPERVIOUS;
- mPrintf("\n entry cmd: ");
- switch (toUpper(iChar())) {
- case 'A':
- mPrintf("bort\n ");
- if (getYesNo(" confirm")) {
- msgBuf.mbto[0] = 0;
- msgBuf.mbaddr[0] = 0;
- return FALSE;
- }
- break;
- case 'C':
- mPrintf("ontinue");
- doCR();
- return ERROR;
- case 'P':
- mPrintf("rint formatted\n ");
- doCR();
- outFlag = OUTOK;
- mPrintf( " ");
- printDate();
- if (loggedIn)
- mPrintf(" from %s", msgBuf.mbauth);
- if (thisRoom == MAILROOM)
- mPrintf(" to %s", msgBuf.mbto);
- if (msgBuf.mbaddr[0])
- mPrintf(" (on %s)", msgBuf.mbaddr);
- doCR();
- mFormat(buf);
- break;
- case 'R':
- mPrintf("eplace string\n ");
- replaceString(buf, lim);
- break;
- case 'S':
- mPrintf("ave buffer\n ");
- return TRUE;
- case 'H':
- mPrintf("old message for later\n ");
- if (heldMessage) {
- mPrintf("Message already being held!\n ");
- break;
- }
- mPrintf("Message held\n ");
- strTran(tempMess.mbtext, msgBuf.mbtext);
- if (msgBuf.mbto[0] != 0)
- strTran(tempMess.mbto, msgBuf.mbto);
- if (msgBuf.mbaddr[0] != 0)
- strTran(tempMess.mbaddr, msgBuf.mbaddr);
- heldMessage = TRUE;
- return HELD;
- case '?':
- tutorial("edit.mnu");
- break;
- default:
- if (!expert) tutorial("edit.mnu");
- else mPrintf(" ? (Type '?' for menu)\n \n");
- break;
- }
- } while (onLine());
- return FALSE;
- }
-
- /************************************************************************/
- /* findRoom() returns # of free room if possible, else ERROR */
- /************************************************************************/
- int findRoom()
- {
- int roomRover;
-
- for (roomRover = 0; roomRover < MAXROOMS; roomRover++) {
- if (roomTab[roomRover].rtflags.INUSE == 0) return roomRover;
- }
- return ERROR;
- }
-
- /************************************************************************/
- /* getNumber() prompts for a number in (bottom, top) range. */
- /************************************************************************/
- int getNumber(prompt, bottom, top)
- char *prompt;
- unsigned bottom;
- unsigned top;
- {
- unsigned try;
- char numstring[NAMESIZE];
-
- do {
- getString(prompt, numstring, NAMESIZE, FALSE, ECHO);
- try = atoi(numstring);
- if (try < bottom) mPrintf("Sorry, must be at least %d\n", bottom);
- if (try > top ) mPrintf("Sorry, must be no more than %d\n", top);
- } while ((try < bottom || try > top) && onLine());
- return try;
- }
-
- /************************************************************************/
- /* getString() gets a string from the user. */
- /************************************************************************/
- getString(prompt, buf, lim, QuestIsSpecial, doEcho)
- char *prompt;
- char *buf;
- char doEcho;
- int lim; /* max # chars to read */
- char QuestIsSpecial; /* Return immediately on '?' input? */
- {
- char c, oldEcho;
- int i;
-
- outFlag = IMPERVIOUS;
-
- if (strLen(prompt) > 0) {
- doCR();
- mPrintf("Enter %s\n : ", prompt, lim);
- }
-
- oldEcho = echo;
- if (!doEcho) {
- echo = NEITHER;
- echoChar = 'X';
- }
-
- i = 0;
- while (
- c = iChar(),
-
- c != NEWLINE
- && i < lim
- && onLine()
- ) {
- outFlag = OUTOK;
-
- /* handle delete chars: */
- if (c == BACKSPACE) {
- oChar(' ');
- oChar(BACKSPACE);
- if (i > 0) i--;
- else {
- oChar(' ');
- oChar(BELL);
- }
- } else buf[i++] = c;
-
- if (i >= lim) {
- oChar(BELL);
- oChar(BACKSPACE); i--;
- }
-
- /* kludge to return immediately on single '?': */
- if (QuestIsSpecial && *buf == '?') {
- doCR();
- break;
- }
- }
- echo = oldEcho;
- buf[i] = '\0';
- }
-
- /************************************************************************/
- /* getText() reads a message from the user */
- /* Returns TRUE if user decides to save it, else FALSE */
- /************************************************************************/
- char getText(prompt, recipient, mode)
- char *prompt;
- char mode;
- char *recipient; /* Meaningful iff thisRoom == MAILROOM */
- {
- #ifdef NEED_VISIBLE
- char visible();
- #endif
- char c, sysopAbort, *buf, beeped = FALSE;
- int i, toReturn, lim;
-
- if (!expert) {
- tutorial("entry.blb");
- mPrintf("Enter %s (end with empty line)", prompt);
- }
- outFlag = OUTOK;
- doCR();
- mPrintf(" ");
- printDate();
- if (loggedIn) mPrintf("from %s", msgBuf.mbauth);
- if (thisRoom == MAILROOM) mPrintf(" to %s", recipient);
- if (msgBuf.mbaddr[0]) mPrintf(" (on %s)", msgBuf.mbaddr);
- doCR();
-
- buf = msgBuf.mbtext;
- if (!mode) {
- buf[-1] = NEWLINE;
- buf[ 0] = 0;
- toReturn = TRUE;
- }
- else {
- outFlag = OUTOK;
- mFormat(buf);
- outFlag = OUTOK;
- doCR();
- toReturn = ERROR;
- }
- outFlag = OUTOK;
- lim = MAXTEXT;
-
- lim--;
- i = strLen(buf);
- sysopAbort = FALSE;
- do {
- #ifdef NOTFASTENOUGH
- if (whichIO == MODEM) {
- fastIn(toReturn == ERROR);
- if (whichIO != MODEM) sysopAbort = TRUE;
- } else {
- #endif
- /* this code would handle the modem as well... */
- /* fastIn() is a later addition to handle people */
- /* who like to upload fast without handshaking */
- i = strLen(buf);
- while (
- !(
- (c=iChar()) == NEWLINE &&
- (buf[i-1] == NEWLINE || i == 0)
- )
- && i < lim
- && onLine()
- ) {
- #ifdef NEED_VISIBLE
- if (debug) mputChar(visible(c));
- #endif
-
- if (c != BACKSPACE) {
- if (c != 0) buf[i++] = c;
- if (i > MAXTEXT - 80 && !beeped) {
- beeped = TRUE;
- oChar(BELL);
- }
- }
- else {
- /* handle delete chars: */
- oChar(' ');
- oChar(BACKSPACE);
- if (i > 0 && buf[i-1] != NEWLINE) i--;
- else oChar(BELL);
- }
- /* } */
-
- buf[i] = 0x00; /* null to terminate message */
-
- if (i == lim) mPrintf(" buffer overflow\n ");
- }
- toReturn = sysopAbort ? FALSE : editText(buf, lim);
- } while ((toReturn == ERROR) && onLine());
- if (toReturn == TRUE) { /* Filter null messages */
- toReturn = FALSE;
- for (i = 0; buf[i] != 0 && toReturn == FALSE; i++)
- toReturn = (buf[i] > ' ' && buf[i] < 127);
- }
- return toReturn;
- }
-
- /************************************************************************/
- /* getYesNo() prompts for a yes/no response */
- /************************************************************************/
- char getYesNo(prompt)
- char *prompt;
- {
- int toReturn;
-
- for (doCR(), toReturn = ERROR; toReturn == ERROR && onLine(); ) {
- outFlag = IMPERVIOUS;
- mPrintf("%s? (Y/N): ", prompt);
-
- switch (toUpper(iChar())) {
- case 'Y': toReturn = TRUE ; break;
- case 'N': toReturn = FALSE; break;
- }
- doCR();
- }
- outFlag = OUTOK;
- return toReturn;
- }
-
- /************************************************************************/
- /* givePrompt() prints the usual "CURRENTROOM>" prompt. */
- /************************************************************************/
- givePrompt()
- {
- outFlag = IMPERVIOUS;
- doCR();
- if (loggedIn) printf("(%s)\n", logBuf.lbname);
- mPrintf(roomBuf.rbflags.MSDOSDIR == 0 ? "%s> " : "%s] ", roomBuf.rbname);
-
- if (strCmp(roomBuf.rbname, roomTab[thisRoom].rtname) != SAMESTRING) {
- exitValue = CRASH_EXIT;
- crashout("Dependent variables mismatch!");
- }
- outFlag = OUTOK;
- }
-
- /************************************************************************/
- /* good_path() Gets a valid path from the sysop. Drive should be */
- /* set already. */
- /************************************************************************/
- good_path(buffer, size)
- char *buffer;
- int size;
- {
- char *cd, *gcdir();
- char gooddir;
-
- cd = gcdir("");
- buffer[0] = '\\';
- do {
- mPrintf("\n Path: \\");
- getString("", buffer+1, size - 1, FALSE, ECHO, FALSE);
- gooddir = ((chdir(buffer) != EOF) || buffer[1] == '?');
- if (!gooddir) printf("Directory not found.\n");
- } while (!gooddir);
- chdir(cd);
- free(cd);
- }
-
- /************************************************************************/
- /* indexRooms() -- build RAM index to CTDLROOM.SYS, by CITADEL, to */
- /* delete empty rooms. */
- /************************************************************************/
- indexRooms()
- {
- int goodRoom, m, slot;
-
- for (slot = 0; slot < MAXROOMS; slot++) {
- if (roomTab[slot].rtflags.INUSE == 1) {
- goodRoom = FALSE;
- if (roomTab[slot].rtlastMessage > cfg.oldest ||
- roomTab[slot].rtflags.PERMROOM == 1) {
- goodRoom = TRUE;
- }
-
- if (!goodRoom) {
- getRoom(slot);
- roomBuf.rbflags.INUSE = 0;
- roomBuf.rbflags.MSDOSDIR = 0;
- roomBuf.rbflags.PERMROOM = 0;
- roomBuf.rbflags.INUSE = 0;
- putRoom(slot);
- strCat(msgBuf.mbtext, roomBuf.rbname);
- strCat(msgBuf.mbtext, "> ");
- noteRoom();
- }
- }
- }
- }
-
- /************************************************************************/
- /* makeRoom() constructs a new room via dialogue with user. */
- /************************************************************************/
- makeRoom()
- {
- char *nm[NAMESIZE];
- char *oldName[NAMESIZE];
- int i;
-
- /* update lastMessage for current room: */
- logBuf.lbgen[thisRoom] = roomBuf.rbgen << GENSHIFT;
-
- strCpy(oldName, roomBuf.rbname);
- if ((thisRoom = findRoom()) == ERROR) {
- indexRooms(); /* try and reclaim an empty room */
- if ((thisRoom = findRoom()) == ERROR) {
- mPrintf(" ?no room, sorry");
- /* may have reclaimed old room, so: */
- if (roomExists(oldName) == ERROR) strCpy(oldName, baseRoom);
- getRoom(roomExists(oldName));
- return;
- }
- }
-
- getNormStr("name for new room", nm, NAMESIZE, ECHO);
- if (strLen(nm) == 0) {
- if (roomExists(oldName) == ERROR) strCpy(oldName, baseRoom);
- getRoom(roomExists(oldName));
- return ;
- }
-
- if (roomExists(nm) >= 0) {
- mPrintf(" A '%s' already exists.\n", nm);
- /* may have reclaimed old room, so: */
- if (roomExists(oldName) == ERROR) strCpy(oldName, baseRoom);
- getRoom(roomExists(oldName));
- return;
- }
- if (!expert) tutorial("newroom.blb");
-
- roomBuf.rbflags.INUSE = TRUE;
- roomBuf.rbflags.PERMROOM = FALSE;
- roomBuf.rbflags.MSDOSDIR = FALSE;
- if (getYesNo(" Make room public")) roomBuf.rbflags.PUBLIC = TRUE;
- else roomBuf.rbflags.PUBLIC = FALSE;
-
- mPrintf("'%s', a %s room",
- nm,
- roomBuf.rbflags.PUBLIC == 1 ? "public" : "private"
- );
-
- if(!getYesNo("Install it")) {
- /* may have reclaimed old room, so: */
- if (roomExists(oldName) == ERROR) strCpy(oldName, baseRoom);
- getRoom(roomExists(oldName));
- return;
- }
-
- strCpy(roomBuf.rbname, nm);
- for (i = 0; i < MSGSPERRM; i++) {
- roomBuf.msg[i].rbmsgNo = 0l; /* mark all slots empty */
- roomBuf.msg[i].rbmsgLoc = 0 ;
- }
- roomBuf.rbgen = (roomTab[thisRoom].rtgen + 1) % MAXGEN;
-
- noteRoom(); /* index new room */
- putRoom(thisRoom);
-
- /* update logBuf: */
- logBuf.lbgen[thisRoom] = roomBuf.rbgen << GENSHIFT;
- sprintf(msgBuf.mbtext, "%s> created by %s", nm, logBuf.lbname);
- aideMessage(FALSE);
- }
-
- /************************************************************************/
- /* matchString() searches for match to given string. Runs backward*/
- /* through buffer so we get most recent error first. */
- /* Returns loc of match, else ERROR */
- /************************************************************************/
- char *matchString(buf, pattern, bufEnd)
- char *buf, *pattern, *bufEnd;
- {
- char *loc, *pc1, *pc2;
- char foundIt;
-
- for (loc = bufEnd, foundIt = FALSE; !foundIt && --loc >= buf;) {
- for (pc1 = pattern, pc2 = loc, foundIt = TRUE ; *pc1 && foundIt;) {
- if (! (toLower(*pc1++) == toLower(*pc2++))) foundIt = FALSE;
- }
- }
-
- return foundIt ? loc : ERROR;
- }
-
- /************************************************************************/
- /* getNormStr() gets a string and deletes leading */
- /* & trailing blanks etc. */
- /************************************************************************/
- getNormStr(prompt, s, size, doEcho)
- char *s, *prompt;
- char doEcho;
- int size;
- {
- char *pc;
-
- getString(prompt, s, size, FALSE, doEcho);
- pc = s;
-
- /* find end of string */
- while (*pc) {
- if (*pc < ' ') *pc = ' '; /* zap tabs etc... */
- pc++;
- }
-
- /* no trailing spaces: */
- while (pc>s && isSpace(*(pc-1))) pc--;
- *pc = '\0';
-
- /* no leading spaces: */
- while (*s == ' ') {
- for (pc=s; *pc; pc++) *pc = *(pc+1);
- }
-
- /* no double blanks */
- for (; *s; s++) {
- if (*s == ' ' && *(s+1) == ' ') {
- for (pc=s; *pc; pc++) *pc = *(pc+1);
- }
- }
- }
-
- /************************************************************************/
- /* noteRoom() -- enter room into RAM index array. */
- /************************************************************************/
- noteRoom()
- {
- int i;
- ulong last;
-
- last = 0l;
- for (i = 0; i < MSGSPERROOM; i++) {
- if (roomBuf.msg[i].rbmsgNo > last) {
- last = roomBuf.msg[i].rbmsgNo;
- }
- }
- roomTab[thisRoom].rtlastMessage = last ;
- strCpy(roomTab[thisRoom].rtname, roomBuf.rbname) ;
- roomTab[thisRoom].rtgen = roomBuf.rbgen ;
- roomTab[thisRoom].rtflags.INUSE = roomBuf.rbflags.INUSE;
- roomTab[thisRoom].rtflags.PUBLIC = roomBuf.rbflags.PUBLIC;
- roomTab[thisRoom].rtflags.MSDOSDIR = roomBuf.rbflags.MSDOSDIR;
- roomTab[thisRoom].rtflags.PERMROOM = roomBuf.rbflags.PERMROOM;
- roomTab[thisRoom].rtflags.SKIP = roomBuf.rbflags.SKIP;
- }
-
- /************************************************************************/
- /* renameRoom() is sysop special fn */
- /* Returns: TRUE on success else FALSE */
- /************************************************************************/
- renameRoom()
- {
- char nm[NAMESIZE];
- char c, goodOne, wasDirectory;
- int r;
-
- if ( /* clearer than "thisRoom <= AIDEROOM"*/
- thisRoom == LOBBY
- ||
- thisRoom == MAILROOM
- ||
- thisRoom == AIDEROOM
- ) {
- mPrintf("? -- may not edit this room.\n ");
- return FALSE;
- }
-
- if (!getYesNo("confirm")) return FALSE;
-
- if (getYesNo("Change name")) {
- getNormStr("new room name", nm, NAMESIZE, ECHO);
- r = roomExists(nm);
- if (r >= 0 && r != thisRoom) {
- mPrintf("A %s exists already!\n", nm);
- } else {
- strCpy(roomBuf.rbname, nm); /* also in room itself */
- }
- }
- mPrintf("%s, ", roomBuf.rbflags.PUBLIC == 1 ? "public" : "private");
- mPrintf(
- "%s, ",
- (
- (roomBuf.rbflags.PERMROOM == 1)
- ?
- " permanent"
- :
- " temporary"
- )
- );
- wasDirectory = roomBuf.rbflags.MSDOSDIR;
- mPrintf("%sdirectory room\n ", wasDirectory ? "" : "non");
-
- roomBuf.rbflags.INUSE = TRUE;
-
- if (getYesNo("Public room")) {
- roomBuf.rbflags.PUBLIC = TRUE;
- } else {
- roomBuf.rbflags.PUBLIC = FALSE; /* JUST in case */
- if (getYesNo("Cause non-aide users to forget room"))
- roomBuf.rbgen = (roomBuf.rbgen +1) % MAXGEN;
- }
-
- if (!onConsole) roomBuf.rbflags.MSDOSDIR = wasDirectory;
- else if (getYesNo("Directory room")) {
- if (roomBuf.rbflags.MSDOSDIR == TRUE)
- printf("Currently drive %c, directory %s\n",
- 'A'+roomBuf.rbdisk,
- (strLen(roomBuf.rbdirname) == 0 ? "is current directory" : roomBuf.rbdirname));
-
- roomBuf.rbflags.MSDOSDIR = TRUE;
-
- for (goodOne = FALSE; !goodOne; ) {
- getString("disk", nm, NAMESIZE, FALSE, ECHO);
- c = toUpper(nm[0]);
- if (c>='A' && c<='P') {
- roomBuf.rbdisk = c - 'A';
- goodOne = TRUE;
- } else printf("?");
- }
- setSpace(roomBuf.rbdisk, "");
-
- for (goodOne = FALSE; !goodOne; ) {
- getString("directory (empty entry means use current directory)",
- nm, 9, FALSE, ECHO);
- if (index(nm, ' ') != NULL)
- printf("No spaces in directory names!");
- else if (index(nm, '\\') != NULL)
- printf("No '\\'s in directory names!");
- else if (strLen(nm) == 0) {
- goodOne = TRUE;
- strCpy(roomBuf.rbdirname, nm);
- }
- else if (chdir(nm) != EOF) {
- printf("%s exists. ", nm);
- goodOne = getYesNo("Use it");
- chdir("..");
- if (goodOne)
- strCpy(roomBuf.rbdirname, nm);
- }
- else {
- printf("%s does not exist. ", nm);
- goodOne = getYesNo("Create");
- if (goodOne) {
- if (mkdir(nm) == EOF) {
- printf("?ERROR CREATING!");
- roomBuf.rbflags.MSDOSDIR = FALSE;
- }
- else strCpy(roomBuf.rbdirname, nm);
- }
- }
- }
- setSpace(cfg.homeDisk, "");
- }
- else
- roomBuf.rbflags.MSDOSDIR = FALSE;
-
- if (roomBuf.rbflags.MSDOSDIR == TRUE || getYesNo("permanent")) {
- roomBuf.rbflags.PERMROOM = TRUE;
- }
- else
- roomBuf.rbflags.PERMROOM = FALSE;
-
- noteRoom();
- putRoom(thisRoom);
-
- return TRUE;
- }
-
- /************************************************************************/
- /* replaceString() corrects typos in message entry */
- /************************************************************************/
- replaceString(buf, lim)
- char *buf;
- int lim;
- {
- char oldString[2*SECTSIZE];
- char newString[2*SECTSIZE];
- char *loc, *textEnd;
- char *pc;
- int incr, length;
-
- /* find terminal null */
- for (textEnd = buf, length = 0; *textEnd; length++, textEnd++);
-
- getString("string", oldString, (2*SECTSIZE), FALSE, ECHO);
- if ((loc=matchString(buf, oldString, textEnd)) == ERROR) {
- mPrintf("?not found.\n ");
- return;
- }
-
- getString("replacement", newString, (2*SECTSIZE), FALSE, ECHO);
- if ( (strLen(newString)-strLen(oldString)) >= lim - length) {
- mPrintf("?Overflow!\n ");
- return;
- }
-
- /* delete old string: */
- for (pc=loc, incr=strLen(oldString); *pc=*(pc+incr); pc++);
- textEnd -= incr;
-
- /* make room for new string: */
- for (pc=textEnd, incr=strLen(newString); pc>=loc; pc--) {
- *(pc+incr) = *pc;
- }
-
- /* insert new string: */
- for (pc=newString; *pc; *loc++ = *pc++);
- }
-
- /************************************************************************/
- /* strTran() Transfers a string from loc to dest, then zaps loc */
- /************************************************************************/
- strTran(dest, loc)
- char *dest, *loc;
- {
- strCpy(dest, loc);
- loc[0] = 0;
- }
-